package com.acce.gxsc.page.registerCar.addCustomInfo;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.acce.gxsc.R;
import com.acce.sdk.base.mvp.BaseMvpActivity;
import com.acce.sdk.widget.AcceBar;
import com.acce.sdk.widget.EditWithTitle;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by huxley on 2017/5/26.
 */

public class AddCustomInfoActivity extends BaseMvpActivity<AddCustomInfoView, AddCustomInfoPresenter> implements AddCustomInfoView {

    @Bind(R.id.accebar)
    AcceBar       mAccebar;
    @Bind(R.id.ewt_name)
    EditWithTitle mEwtName;
    @Bind(R.id.ewt_phone)
    EditWithTitle mEwtPhone;

    @Override
    protected AddCustomInfoPresenter createPresenter() {
        return new AddCustomInfoPresenter();
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_custom_info);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        Intent intent = getIntent();
        if (intent == null) {
            return;
        }
        if (intent.hasExtra("name")) {
            mEwtName.setContent(intent.getStringExtra("name"));
        }
        if (intent.hasExtra("phone")) {
            mEwtPhone.setContent(intent.getStringExtra("phone"));
        }
    }

    @OnClick(R.id.btn_add)
    public void onClick() {
        String name = mEwtName.getContent();
        String phone = mEwtPhone.getContent();
//        if (!StringUtils.areNotEmpty(name)) {
//            ToastUtils.show("请填写货主姓名！");
//            return;
//        }
        Intent intent = new Intent();
        intent.putExtra("name", name);
        intent.putExtra("phone", phone);
        setResult(RESULT_OK, intent);
        finish();
    }
}
